home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <intuition/gadgetclass.h>
-
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <string.h>
-
- #include "/include/server.h"
-
- struct Gadget *glist, *gad, *timeout_gdg, *active_gdg,
- *random_gdg, *hide_gdg, *quit_gdg, *blank_gdg, *modeid_gdg,
- *kill_gdg, *list_gdg;
- extern struct List ClientsList, *ModeList;
- extern struct ModeNode *DisplayNode;
- extern UWORD delaySecs;
- extern BOOL CommodityActive, RandomClient;
- extern UWORD DefaultClient;
-
- extern void FreeClientsList( void );
- extern struct List *CreateModeList( void );
- extern void DeleteModeList( void );
- extern void GetDisplayNodeFromID( void );
-
- /****************
- * *
- * GADGETS STUFF *
- * *
- ****************/
-
- struct VisualInfo *vi;
- UWORD fonth;
- struct NewGadget newgdg = { 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0 };
- struct Screen *WBS;
- struct Library *GadToolsBase;
- struct IntuitionBase *IntuitionBase;
- UWORD wleft = (UWORD)~0, wtop = (UWORD)~0;
-
- struct TextAttr topazFont = { "topaz.font", 8, NULL, FPF_ROMFONT };
-
- BOOL SetUpGadgets( void )
- {
- if ( CreateModeList() )
- {
- GetDisplayNodeFromID();
-
- if ( WBS = LockPubScreen( NULL ) )
- {
- fonth = WBS->Font->ta_YSize;
-
- if ( wleft == ~0 && wtop == ~0 )
- {
- wleft = (WBS->Width - 300)>>1;
- wtop = (WBS->Height - fonth - 138 )>>1;
- }
-
- if ( vi = GetVisualInfo( WBS, TAG_END ) )
- {
- gad = CreateContext (&glist);
-
- newgdg.ng_Flags = PLACETEXT_LEFT;
- newgdg.ng_TopEdge = WBS->WBorTop + fonth + 4;
- newgdg.ng_Height = 12;
- newgdg.ng_TextAttr = &topazFont;
- newgdg.ng_VisualInfo = vi;
-
- newgdg.ng_Width = 38;
- newgdg.ng_LeftEdge = WBS->WBorLeft + 70;
- newgdg.ng_GadgetText = "TimeOut";
- timeout_gdg = gad = CreateGadget( INTEGER_KIND, gad, &newgdg,
- GTIN_Number, delaySecs,
- GTIN_MaxChars, 5,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = RANDOM_GDG;
- newgdg.ng_TopEdge += 14;
- newgdg.ng_LeftEdge = WBS->WBorLeft + 82;
- newgdg.ng_GadgetText = "_Random";
- random_gdg = gad = CreateGadget( CHECKBOX_KIND, gad, &newgdg,
- GTCB_Checked, RandomClient,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = ACTIVE_GDG;
- newgdg.ng_TopEdge += 12;
- newgdg.ng_GadgetText = "_Active";
- active_gdg = gad = CreateGadget( CHECKBOX_KIND, gad, &newgdg,
- GTCB_Checked, CommodityActive,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = HIDE_GDG;
- newgdg.ng_TopEdge += 14;
- newgdg.ng_LeftEdge = WBS->WBorLeft + 8;
- newgdg.ng_Flags = 0;
- newgdg.ng_Width = 100;
- newgdg.ng_GadgetText = "_Hide";
- hide_gdg = gad = CreateGadget( BUTTON_KIND, gad, &newgdg,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = QUIT_GDG;
- newgdg.ng_TopEdge += 14;
- newgdg.ng_GadgetText = "_Quit";
- quit_gdg = gad = CreateGadget( BUTTON_KIND, gad, &newgdg,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = BLANK_GDG;
- newgdg.ng_TopEdge += 14;
- newgdg.ng_GadgetText = "_Blank";
- blank_gdg = gad = CreateGadget( BUTTON_KIND, gad, &newgdg,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = KILL_GDG;
- newgdg.ng_TopEdge = WBS->WBorTop + fonth + 72;
- newgdg.ng_LeftEdge = WBS->WBorLeft + 124;
- newgdg.ng_Width = 160;
- newgdg.ng_GadgetText = "_Kill selected";
- kill_gdg = gad = CreateGadget( BUTTON_KIND, gad, &newgdg,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = SHOWINTERFACE_GDG;
- newgdg.ng_TopEdge -= 14;
- newgdg.ng_Width = 160;
- newgdg.ng_GadgetText = "Add _client";
- kill_gdg = gad = CreateGadget( BUTTON_KIND, gad, &newgdg,
- GT_Underscore, '_', TAG_END );
-
- newgdg.ng_GadgetID = LIST_GDG;
- newgdg.ng_TopEdge = WBS->WBorTop + fonth + 4;
- newgdg.ng_GadgetText = NULL;
- newgdg.ng_Height = 57;
- newgdg.ng_Flags = PLACETEXT_ABOVE;
- list_gdg = gad = CreateGadget( LISTVIEW_KIND, gad, &newgdg,
- GTLV_Labels, &ClientsList,
- GTLV_ShowSelected, NULL,
- GTLV_Top, DefaultClient,
- GTLV_Selected, DefaultClient,
- TAG_END );
-
- newgdg.ng_GadgetID = MODEID_GDG;
- newgdg.ng_TopEdge = WBS->WBorTop + fonth + 86;
- newgdg.ng_LeftEdge = WBS->WBorLeft + 8;
- newgdg.ng_Width = 276;
- newgdg.ng_Height = 49;
- newgdg.ng_GadgetText = NULL;
- modeid_gdg = gad = CreateGadget( LISTVIEW_KIND, gad, &newgdg,
- GTLV_Labels, ModeList,
- GTLV_ShowSelected, NULL,
- GTLV_Top, DisplayNode->mn_Index,
- GTLV_Selected, DisplayNode->mn_Index,
- TAG_END );
-
- /* Set up gadgets */
- if ( gad )
- return( TRUE );
-
- FreeGadgets( glist );
- }
- FreeVisualInfo( vi );
- vi = NULL;
- }
- UnlockPubScreen( NULL, WBS );
- }
- DeleteModeList();
-
- return( FALSE );
- }
-
-
- void RemoveGadgets( void )
- {
- FreeGadgets( glist );
- FreeVisualInfo( vi );
- UnlockPubScreen( NULL, WBS );
- DeleteModeList();
- }
-